package wint.mvc.view.types;

import java.io.IOException;
import java.io.Writer;

import wint.mvc.flow.InnerFlowData;
import wint.mvc.template.Context;
import wint.mvc.view.types.json.FastJsonRender;
import wint.mvc.view.types.json.JsonRender;

public class JsonViewRender extends AbstractViewRender {

	public static final String TYPE_NAME = "json";
	
	private JsonRender jsonRender = new FastJsonRender();
	
	@Override
	public String getViewType() {
		return TYPE_NAME;
	}

	@Override
	public void render(Context context, InnerFlowData flowData, String target, String moduleType) {
		try {
			Writer out = flowData.getWriter();
			jsonRender.render(context, out);
			out.close();
		} catch (IOException e) {
			log.error("json render error", e);
		}
	}

}
